//
//  MUser.swift
//  iOSweibo
//
//  Created by lzm on 16/5/18.
//  Copyright © 2016年 lzm. All rights reserved.
//

import UIKit

class MUser: NSObject {

    //用户ID
    var id : Int64 = 0
    //用户昵称
    var screen_name : String?
    //用户头像地址 50*50
    var profile_image_url : String?
    // verified_type 没有认证:-1   认证用户:0  企业认证:2,3,5  达人:220
    var verifiedType : UIImage?
    var verified_type: Int = -1{
        didSet{
            switch verified_type{
            case 0:
                verifiedType = UIImage(named: "avatar_enterprise_vip")
            case 2,3,5:
                verifiedType = UIImage(named: "avatar_enterprise_vip")
            case 220:
                verifiedType = UIImage(named: "avatar_grassroot")
            default:
                verifiedType = nil
            }
        }
    }
    // 会员等级 1-6
    var memberImage : UIImage?
    var mbrank: Int = 0{
        didSet{
            if mbrank > 0 && mbrank <= 6{
                memberImage = UIImage(named: "common_icon_membership_level\(mbrank)")
            }
            else
            {
                return memberImage = nil
            }
        }
    }
    init(dict:[String : AnyObject]) {
        super.init()
        setValuesForKeysWithDictionary(dict)
    }
    
//    override func setValuesForKeysWithDictionary(keyedValues: [String : AnyObject]) {}
    
    /*-------------我擦你, 这个才是字典转模型找不到Key时,系统抛出异常的方法,不是上面那个方法!!!--------------*/
    /*-------------我擦你, 这个才是字典转模型找不到Key时,系统抛出异常的方法,不是上面那个方法!!!--------------*/
    /*-------------我擦你, 这个才是字典转模型找不到Key时,系统抛出异常的方法,不是上面那个方法!!!--------------*/
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {}
    
    override var description: String {
        get {
            let keys = ["id", "screen_name", "profile_image_url", "verified_type", "mbrank"]
            
            return "\n \t \t用户模型: \(dictionaryWithValuesForKeys(keys))"
        }
    }

}
